﻿using System;
using System.Collections.Generic;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class RegionBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an region to db
        /// </summary>
        /// <param name="region">The region.</param>
        /// <returns></returns>
        public static int Insert(Region region)
        {
            region.CreateAt = DateTime.Now;
            region.CreateBy = MySession.UserID;
            region.UpdateAt = null;
            region.UpdateBy = null;
            return RegionDAL.Insert(region);
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a Region Exists in Database 
        /// </summary>
        /// <param name="region">A region.</param>
        /// <returns></returns>
        public static bool Update(Region region)
        {
            region.UpdateAt = DateTime.Now;
            region.UpdateBy = MySession.UserID;
            return RegionDAL.Update(region);
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a Region Existst in Database
        /// </summary>
        /// <param name="regionID"> </param>
        /// <returns></returns>
        public static bool Delete(int regionID)
        {
            return RegionDAL.Delete(regionID);
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All Region
        /// </summary>
        /// <returns></returns>
        public static RegionList GetAllRegion()
        {
            return RegionDAL.GetAllRegion() ?? new RegionList();
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All Region Parent
        /// </summary>
        /// <returns></returns>
        public static List<Region> GetAllRegionParent()
        {
            //return RegionDAL.GetAllRegionParent() ?? new RegionList();
            return RegionDAL.GetAllRegionParent() ?? new List<Region>();
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a Region existst in Database
        /// </summary>
        /// <param name="regionID">The region ID.</param>
        /// <returns></returns>
        public static Region GetRegionById(int regionID)
        {
            return RegionDAL.GetRegionById(regionID);
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All NewsCategory
        /// </summary>
        /// <returns></returns>
        public static RegionJoinList GetAllRegionJoin()
        {
            try
            {
                return RegionDAL.GetAllRegionJoin() ?? new RegionJoinList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}